package oving1 ; 


public class ArrayMethods1 { 
	static // find the smallest index of value in array
int indexOf (int [] array , int value ) { 
		for(int i=0;i<array.length;i++){
			if(array[i]==value){
				return i;
			}
		}
		// return an illegal index
return - 1 ; 
	} 
	static // find the largest index of value in array
int lastIndexOf (String [] array , String value ) { 
		int index=0;
		boolean fant=false;
		for(int i=0;i<array.length;i++){
			if(array[i]==value){
				index=i;
				fant=true;
			}
		}
		if(fant){
			return index;
		}
		else{
			return - 1 ; 
		}
	} 
	static // find the index of the smallest value in array, starting at start
int indexOfSmallest (int [] array , int start ) { 
	if(array.length>1){
		int smallest=array[start];
		int smallestIndex= start;
		for(int i = start;i<array.length;i++){
			if(array[i]<smallest){
				smallestIndex=i;
			}
		}
		return smallestIndex ; 
	} 
	else{
		return -1;
	}
}

	static int [] intArray = {1,4,5,1} ; 
	static String [] stringArray = { "1" , "2" , "3" , "4" , "3" , "2" , "1" } ; 
	static { 
		System .out .println ( "indexOf(intArray, 3) is " + indexOf ( intArray , 3 ) ) ; 
		System .out .println ( "lastIndexOf(stringArray, \"3\") is " + lastIndexOf ( stringArray , "3" ) ) ; 
		System .out .println ( "indexOfSmallest(intArray, 1) is " + indexOfSmallest ( intArray , 0 ) ) ; 
	} 
	public static void main (java.lang.String args [] ) { 
	} 
} 

